package com.wyp.service.controller.superadmin;

import com.wyp.service.entity.bo.HeadLine;
import com.wyp.service.entity.dto.Result;
import com.wyp.service.service.combine.HeadLineShopCategoryCombineService;
import com.wyp.service.service.solo.HeadLineService;
import lombok.Getter;
import org.simpleframework.core.annotation.Controller;
import org.simpleframework.inject.annotation.Autowired;
import org.simpleframework.mvc.annotation.RequestMapping;
import org.simpleframework.mvc.annotation.RequestParm;
import org.simpleframework.mvc.annotation.ResponseBody;
import org.simpleframework.mvc.type.ModelAndView;
import org.simpleframework.mvc.type.RequestMethod;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@Getter
@RequestMapping("/head")
public class HeadLineOperationController {
    @Autowired("HeadLineShopCategoryCombineServiceImpl")
    private HeadLineShopCategoryCombineService headLineShopCategoryCombineService;

    @Autowired(value = "HeadLineServiceImpl")
    private HeadLineService headLineService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ModelAndView addHeadLine(@RequestParm("lineName") String lineName,
                                    @RequestParm("lineLink") String lineLink) {
        HeadLine headLine = new HeadLine();
        headLine.setLineName(lineName);
        headLine.setLineLink(lineLink);
        Result<HeadLine> result = headLineService.addHeadLine(headLine);
        ModelAndView m = new ModelAndView();
        m.setView("addheadline.jsp").addViewData("result", result);
        return m;
    }

    @RequestMapping("/remove")
    public void removeHeadLine() {
        throw new RuntimeException("测试异常结果处理器");
    }

    public Result<Boolean> modifyHeadLine(HttpServletRequest req, HttpServletResponse resp) {
        //TODO:参数校验以及请求参数转化
        return null;
    }

    public Result<HeadLine> queryHeadLineById(HttpServletRequest req, HttpServletResponse resp) {
        //TODO:参数校验以及请求参数转化
        return null;
    }

    public Result<List<HeadLine>> queryHeadLine() {
        return null;
    }


}
